<%@ page import="org.xilin.Role; org.xilin.User" %>

<g:setProvider library="jquery"/>

<div>
    <g:if test="${flash.message}">
      <div class="message" style="display:none">${flash.message}</div>
    </g:if>
    <g:hasErrors>
      <div class="errors">
          <g:renderErrors bean="${userInstance}" as="list" />
      </div>
    </g:hasErrors>
    <g:formRemote name="saveFamily" url="${[action:'adminSave']}" method="post" update="cluetip-inner" before="beforeSave()" onComplete="processResponse()">
        <g:hiddenField name="view" value="adminCreate" />
        <g:hiddenField name="id" value="${userInstance?.id}" />
        <div class="dialog">
            <table>
                <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="authority"><g:message code="role.authority.label" default="Role" /></label>
                        </td>
                        <td valign="top" class="value">
                            <g:select name="authority" from="${Role.authorities}" value="${authority}"/>
                        </td>
                    </tr>
                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="username"><g:message code="user.username.label" default="Username" /></label>
                        </td>
                      <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'username', 'errors')}">
                        <g:textField name="username" value="${userInstance?.username}" />
                      </td>
                    </tr>
                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="passwd"><g:message code="user.passwd.label" default="Password" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'passwd', 'errors')}">
                          <g:passwordField name="passwd" value="${userInstance?.passwd}" />
                        </td>
                    </tr>
                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="email"><g:message code="user.email.label" default="Email" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'email', 'errors')}">
                          <g:textField name="email" value="${userInstance?.email}" />
                        </td>
                    </tr>
                <tr class="prop">
                    <td valign="top" class="name">
                      <label for="emailShow"><g:message code="user.emailShow.label" default="Show Email" /></label>
                    </td>
                    <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'enabled', 'errors')}">
                      <g:select name="emailShow" from="${['Show','Hide']}" keys="[1,0]" value="${userInstance?.emailShow}"/>
                    </td>
                </tr>
                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="enabled"><g:message code="user.enabled.label" default="User Enabled" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'enabled', 'errors')}">
                          <g:select name="enabled" from="${['Enabled','Disabled']}" keys="[1,0]" value="${userInstance?.enabled}"/> 
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <br/>
        <div class="buttons">
            <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Save')}" /></span>
            <span class="button"><input type="reset" value="${message(code: 'default.button.clear.label', default: 'Reset')}" /></span>
        </div>
    </g:formRemote>
</div>
